//
//  UIViewController+ForceOrientation.m
//  _HealthDetector
//
//  Created by lanzhongping on 2020/4/26.
//  Copyright © 2020 . All rights reserved.
//

#import "UIViewController+More.h"


@implementation UIViewController (More)


- (void)showAlertWarningWithTitle:(NSString *)title Msg:(NSString *)msg btnCancel:(NSString *)btnTitle Compelete:(void (^ __nullable)(void))completion {

    dispatch_async(dispatch_get_main_queue(), ^{
         UIAlertController *alert = [UIAlertController alertControllerWithTitle:title message:msg preferredStyle:UIAlertControllerStyleAlert];
           UIAlertAction *sure = [UIAlertAction actionWithTitle:btnTitle style:UIAlertActionStyleCancel handler:nil];
           [alert addAction:sure];
           [self presentViewController:alert animated:YES completion:completion];
    });
   
}

- (void)showAlertWarningWithTitle:(NSString *)title
                              Msg:(NSString *)msg
                            btnOk:(nullable NSString  *)btnTitle
                            OkBLk:(void (^ __nullable)(void))okBlk
                        CancelBtn:(nullable NSString *)cancelTitle
                        CancelBlk:(void (^ __nullable)(void))cancelBlk
                        Compelete:(void (^ __nullable)(void))completion {

    dispatch_async(dispatch_get_main_queue(), ^{
         UIAlertController *alert = [UIAlertController alertControllerWithTitle:title message:msg preferredStyle:UIAlertControllerStyleAlert];
        if (cancelTitle) {
            UIAlertAction *cancel = [UIAlertAction actionWithTitle:cancelTitle style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
                if (cancelBlk) {
                    cancelBlk();
                }
            }];
            [alert addAction:cancel];
        }
        if (btnTitle) {
            UIAlertAction *ok = [UIAlertAction actionWithTitle:btnTitle style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
                if (okBlk) {
                    okBlk();
                }
            }];
            [alert addAction:ok];
        }
          
           [self presentViewController:alert animated:YES completion:completion];
    });
   
}



@end
